<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('工艺流程执行列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>产品批次号：</label>
                                <input type="text" name="prodBatchNo"/>
                            </li>
                            <li>
                                <label>状态：</label>
                                <select name="state" th:with="type=${@dict.getType('data_normal_disable')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li class="select-time">
                                <label>创建时间：</label>
                                <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginCreateTime]"/>
                                <span>-</span>
                                <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endCreateTime]"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>
            <div id="toolbar" class="layui-tab layui-tab-brief" lay-filter="layui-tab">
                <ul class="layui-tab-title">
                    <li class="layui-this" data-value="1">未删除数据列表</li>
                    <li  data-value="0">删除数据列表</li>
                </ul>
                <div class="layui-tab-content">
                <div class="layui-tab-item layui-show">
                    <div class="btn-group-sm" role="group">
                        <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="central:centralArtProcessRun:add">
                            <i class="fa fa-plus"></i> 添加
                        </a>
                        <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="central:centralArtProcessRun:edit">
                            <i class="fa fa-edit"></i> 修改
                        </a>
                            <a class="btn btn-success multiple disabled" onclick="$.operation.handleStateToAvailable()" shiro:hasPermission="central:centralArtProcessRun:edit">
                                <i class="fa fa-edit"></i> 启用
                            </a>
                            <a class="btn btn-danger multiple disabled" onclick="$.operation.handleStateToDisabled()" shiro:hasPermission="central:centralArtProcessRun:edit">
                                <i class="fa fa-edit"></i> 禁用
                            </a>
                        <a class="btn btn-danger multiple disabled" onclick="$.operation.removeAll()" shiro:hasPermission="central:centralArtProcessRun:remove">
                            <i class="fa fa-remove"></i> 删除
                        </a>
                        <a class="btn btn-info" onclick="$.operation.importExcel()" shiro:hasPermission="central:centralArtProcessRun:import">
                            <i class="fa fa-upload"></i> 导入
                        </a>
                        <a class="btn btn-warning" onclick="$.operation.exportExcel()" shiro:hasPermission="central:centralArtProcessRun:export">
                            <i class="fa fa-download"></i> 导出
                        </a>
                    </div>
                </div>
                <div class="layui-tab-item">
                    <div class="btn-group-sm"  role="group">
                        <a class="btn btn-success multiple disabled" onclick="$.operation.restoreDataAll()" shiro:hasPermission="system:customColumn:restore">
                            <i class="fa fa-edit"></i> 恢复
                        </a>
                    </div>
                </div>
            </div>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('central:centralArtProcessRun:edit')}]];
        var removeFlag = [[${@permission.hasPermi('central:centralArtProcessRun:remove')}]];

        var stateDatas = [[${@dict.getType('data_normal_disable')}]];
        var restoreFlag = [[${@permission.hasPermi('central:centralArtProcessRun:restore')}]];

        const taskStatusDatas = [[${@dict.getType('sys_task_status')}]]

        layui.use('element', function(){
            var element = layui.element;
            //一些事件触发
            element.on('tab(layui-tab)', function(data){
                $.logicDelete.toggle()
            });
        });


        $(function() {
            var options = {
                requestPrefix: ctx + "central/centralArtProcessRun",
                uniqueId:'id',
                modalName: "工艺流程执行",
                signName: "top_central_art_process_run",
                logicDelete:true,
                columns: [{
                    checkbox: true
                },
                {
                    field: 'id',
                    title: '编号',
                    visible: false,
                    sortable:true,
                },
                {
                    field: 'prodBatchNo',
                    title: '产品批次号',
                    sortable:true,
                    formatter: function(value,row,index){
                        return $.table.tooltip(value);
                    }
                },
                {
                    field: 'prodId',
                    title: '产品编号',
                    sortable:true,
                    formatter: function(value,row,index){
                        return $.table.tooltip(value);
                    }
                },
                {
                    field: 'artProcessId',
                    title: '工艺名称',
                    sortable:true,
                    formatter: function(value,row,index){
                        if(row.artProcessRun){
                            return $.table.tooltip(row.artProcessRun.name);
                        }
                        return $.table.tooltip(value);
                    }
                },
                {
                    field: 'processStepId',
                    title: '工序',
                    sortable:true,
                    formatter: function(value,row,index){
                        return $.table.tooltip(value);
                    }
                },
                {
                    field: 'taskStatus',
                    title: '加工状态',
                    sortable:true,
                    formatter: function(value,row,index){

                        return $.table.selectDictLabel(taskStatusDatas, value);
                    }
                },
                {
                    field: 'state',
                    title: '状态',
                    sortable:true,
                    formatter: function(value, row, index) {
                        if($.logicDelete.isDelFlag()){
                            return $.table.selectDictLabel(stateDatas, value);
                        }else{
                            return $.operation.stateTools(row);
                        }
                    }
                },
                {
                    field: 'createBy',
                    title: '创建者',
                    sortable:true,
                    visible: false,
                    formatter: function(value,row,index){
                        return $.table.tooltip(value);
                    }
                },
                {
                    field: 'createTime',
                    title: '创建时间',
                    sortable:true,
                    visible: false,
                    formatter: function(value,row,index){
                        return $.table.tooltip(value);
                    }
                },
                {
                    field: 'updateBy',
                    title: '修改者',
                    sortable:true,
                    visible: false,
                    formatter: function(value,row,index){
                        return $.table.tooltip(value);
                    }
                },
                {
                    field: 'updateTime',
                    title: '修改时间',
                    sortable:true,
                    visible: false,
                    formatter: function(value,row,index){
                        return $.table.tooltip(value);
                    }
                },
                {
                    field: 'weight',
                    title: '权重',
                    sortable:true,
                    formatter: function(value,row,index){
                        return $.table.tooltip(value);
                    }
                },
                {
                    field: 'remark',
                    title: '描述',
                    sortable:true,
                    formatter: function(value,row,index){
                        return $.table.tooltip(value);
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        if($.logicDelete.isDelFlag()){
                            actions.push('<a class="btn btn-success btn-xs ' + restoreFlag + '" href="javascript:void(0)" onclick="$.operation.restoreData(\'' + row.id + '\')"><i class="fa fa-edit"></i>恢复</a> ');
                        }else{
                            actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                            actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operation.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        }
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
    </script>
</body>
</html>